package com.fingard.dsp.bank.directbank.czcb01;

import com.fingard.dsp.bank.directbank.DirectBase;
import com.fingard.net.WebRequest;

import java.io.UnsupportedEncodingException;

/**
 * @ClassName CZCB01Base
 * @Author 郑章洋
 * @Date 2019/12/18 10:37
 * @Version 1.0
 **/
public class CZCB01Base extends DirectBase {
    protected String getCharset() {
        return getBankConfig().getCharset("UTF-8");
    }

    protected String[] sendToBank(String pReqStr) throws UnsupportedEncodingException {
        WriteBankLogStep2(pReqStr);
        String[] retStr = new String[]{"", ""};
        String tmpAddrUrl = bankFront.serverURL;
        WriteBankLogLn("2.提交到银行的地址：" + tmpAddrUrl);
        WebRequest tmpWebRequest = new WebRequest(tmpAddrUrl);
        tmpWebRequest.setConnectTimeout(60000);
        tmpWebRequest.setRequestProperty("Method", "POST");
        tmpWebRequest.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        tmpWebRequest.setRequestProperty("connection", "close");// 设置连接状态

        byte[] tmpUpBytes = pReqStr.getBytes(getCharset());
        retStr = tmpWebRequest.upload(tmpUpBytes, getCharset());

        WriteBankLogStep3(retStr[1]);
        return retStr;
    }

}
